#include <QLabel>
#include <QMdiArea>
#include <QMdiSubWindow>
#include <QToolBar>
#include <QAction>
#include "MdiAreaMainWin.h"

MdiAreaMainWin::MdiAreaMainWin(QWidget *parent) :
    QMainWindow(parent)
{
    m_mdiArea = new QMdiArea;
    this->setCentralWidget(m_mdiArea);

    actionNew = new QAction(tr("&Open(Ctrl+N)"), this);
    actionNew->setIcon(QIcon("://icons/open.png"));
    actionNew->setShortcut(QKeySequence::New);
    actionNew->setStatusTip(tr("choose a bin image file"));

    connect(actionNew, SIGNAL(triggered()), this, SLOT(slotNewAction()));

    m_fileToolBar = addToolBar(tr("&File"));
    m_fileToolBar->addAction(actionNew);
    m_fileToolBar->setFixedHeight(28);
}

void MdiAreaMainWin::slotNewAction()
{
    QLabel *label = new QLabel(tr("MDI SubWindow!"));
    label->setMinimumSize(300, 200);
    QMdiSubWindow *subWin = new QMdiSubWindow;
    subWin->setWidget(label);
    subWin->setAttribute(Qt::WA_DeleteOnClose);
    m_mdiArea->addSubWindow(subWin);
    subWin->show();
}
